//
//  JSMTouringCell.m
//  TakeYouTourTogether
//
//  Created by dllo on 15/11/30.
//  Copyright © 2015年 king. All rights reserved.
//

#import "JSMTouringCell.h"

@implementation JSMTouringCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}
- (void)createView {
    self.mainImageView = [[BaseImageView alloc]init];
    [self.contentView addSubview:self.mainImageView];
    
    self.userImageView = [[BaseImageView alloc] init];
    [self.contentView addSubview:self.userImageView];
    self.userImageView.layer.borderWidth = 2;
    self.userImageView.layer.cornerRadius = 26;
    self.userImageView.layer.masksToBounds = YES;
    self.userImageView.layer.borderColor = [[UIColor colorWithRed:1.000 green:0.951 blue:0.997 alpha:1.000] CGColor];
    
    self.titleLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:self.titleLabel];
    self.titleLabel.layer.borderWidth = 1;
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.layer.borderColor = [[UIColor whiteColor] CGColor];
    self.titleLabel.font = [UIFont systemFontOfSize:19];
    
    self.userNameLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:self.userNameLabel];
    self.userNameLabel.font = [UIFont systemFontOfSize:13];
    self.userNameLabel.textColor = [UIColor grayColor];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    [self.mainImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).with.offset(10);
        make.left.equalTo(self.contentView).with.offset(15);
        make.right.equalTo(self.contentView).with.offset(-15);
        make.height.mas_equalTo(150*ALL_EDITION_HEIGHT);
    }];

    [self.userNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mainImageView.mas_bottom);
        make.bottom.equalTo(self.contentView).with.offset(-2);
        make.right.equalTo(self.contentView).with.offset(-15);
        make.left.equalTo(self.userImageView.mas_right).with.offset(5);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.mainImageView);
        make.left.equalTo(self.mainImageView).with.offset(52);
        make.left.equalTo(self.mainImageView).with.offset(52);
    }];
    [self.userImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mainImageView.mas_bottom).with.offset(-26);
        make.left.equalTo(self.mainImageView.mas_left);
        make.width.mas_equalTo(52);
        make.height.mas_equalTo(52);
    }];
}
@end
